// routes/users.js
const express = require('express');
const router = express.Router();

// 用户列表查询
router.get('/', (req, res) => {
  res.json([{ id: 1, name: '用户A' }]);
});

// 动态路由参数
router.get('/:userId', (req, res) => {
  res.json({ id: req.params.userId, name: '用户详情' });
});

module.exports = router;

// 主文件app.js
const usersRouter = require('./routes/users');
app.use('/users', usersRouter);